package com.gobang.view;

import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JPanel;

import com.gobang.control.Controller;

public class ChessboardPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	private Controller controller;
	
	public ChessboardPanel(Controller controller) {
		this.controller = controller;
		controller.setChessboardPanel(this);
		initialize();
	}

	private void initialize() {
		this.setLayout(null);
		this.addMouseListener(new MouseAdapter() {

			@Override
			public void mouseClicked(MouseEvent e) {
				ChessboardPanel.this.controller.putPiece(e.getX(), e.getY());
			}
			
		});
	}

	@Override
	protected void paintComponent(Graphics g) {
		controller.drawChessboard(g);
	}
	
	

}
